var phone=request("phone")
$(function(){
	//获取图片
	$.ajax({
	    url: DATA_URL+"getcouchauth",
	    data: "phone="+phone,
	    type: "get",
	    dataType: 'json',
	    timeout: 5000,
	    success:function (data) {
	    	if(data.code=="0"){
	    		$("#jlz_pic").attr("src",data.info.jlz_pic+"?time="+new Date().getTime())
	    		$("#xsz_pic").attr("src",data.info.xsz_pic+"?time="+new Date().getTime())
	    		$("#sfz_pic").attr("src",data.info.sfz_pic+"?time="+new Date().getTime())
	    		$("#jsz_pic").attr("src",data.info.jsz_pic+"?time="+new Date().getTime())
	    		switch(data.info.jlz_status){
	    			case 0:
	    				$("#jlz .tag").attr("class","tag").text("待审核");
	    			break;
	    			case 1:
	    				$("#jlz .tag").attr("class","tag green").text("已审核");
	    			break;
	    			case 2:
	    				$("#jlz .tag").attr("class","tag red").text("未通过");
	    			break;
	    		}
	    		switch(data.info.xsz_status){
	    			case 0:
	    				$("#xsz .tag").attr("class","tag").text("待审核");
	    			break;
	    			case 1:
	    				$("#xsz .tag").attr("class","tag green").text("已审核");
	    			break;
	    			case 2:
	    				$("#xsz .tag").attr("class","tag red").text("未通过");
	    			break;
	    		}
	    		switch(data.info.sfz_status){
	    			case 0:
	    				$("#sfz .tag").attr("class","tag").text("待审核");
	    			break;
	    			case 1:
	    				$("#sfz .tag").attr("class","tag green").text("已审核");
	    			break;
	    			case 2:
	    				$("#sfz .tag").attr("class","tag red").text("未通过");
	    			break;
	    		}
	    		switch(data.info.jsz_status){
	    			case 0:
	    				$("#jsz .tag").attr("class","tag").text("待审核");
	    			break;
	    			case 1:
	    				$("#jsz .tag").attr("class","tag green").text("已审核");
	    			break;
	    			case 2:
	    				$("#jsz .tag").attr("class","tag red").text("未通过");
	    			break;
	    		}
	    		
	    	}
			else{
				$("#prompt").text(data.msg);
	            $(".prompt").fadeIn(300,function(){
	                setTimeout(function(){$(".prompt").fadeOut(300)},3000)
	            })
			}
	    },
	    error:function () {
	    	$("#prompt").text("您的网络不给力哦~");
	        $(".prompt").fadeIn(300,function(){
	            setTimeout(function(){$(".prompt").fadeOut(300)},3000)
	        })
	    }
	});
	//按钮操作
	$(".certificates .btn div").click(function(){
		setsuth($(this).attr("type"),$(this).attr("status"))
	})
	function setsuth(ztype,status){
		//设置认证状态
		$.ajax({
		    url: DATA_URL+"setcouchauth",
		    data: "phone="+phone+"&ztype="+ztype+"&status="+status,
		    type: "post",
		    dataType: 'json',
		    timeout: 5000,
		    success:function (data) {
		    	if(data.code=="0"){
		    		switch(ztype){
		    			case "jlz":
		    				switch(status){
				    			case "1":
				    				$("#jlz .tag").attr("class","tag green").text("已审核");
				    			break;
				    			case "2":
				    				$("#jlz .tag").attr("class","tag red").text("未通过");
				    			break;
				    		}
		    			break;
		    			case "xsz":
		    				switch(status){
				    			case "1":
				    				$("#xsz .tag").attr("class","tag green").text("已审核");
				    			break;
				    			case "2":
				    				$("#xsz .tag").attr("class","tag red").text("未通过");
				    			break;
				    		}
		    			break;
		    			case "sfz":
		    				switch(status){
				    			case "1":
				    				$("#sfz .tag").attr("class","tag green").text("已审核");
				    			break;
				    			case "2":
				    				$("#sfz .tag").attr("class","tag red").text("未通过");
				    			break;
				    		}
		    			break;
		    			case "jsz":
		    				switch(status){
				    			case "1":
				    				$("#jsz .tag").attr("class","tag green").text("已审核");
				    			break;
				    			case "2":
				    				$("#jsz .tag").attr("class","tag red").text("未通过");
				    			break;
				    		}
		    			break;
		    		}
		    		
		    		
		    	}
				else{
					$("#prompt").text(data.msg);
		            $(".prompt").fadeIn(300,function(){
		                setTimeout(function(){$(".prompt").fadeOut(300)},3000)
		            })
				}
		    },
		    error:function () {
		    	$("#prompt").text("您的网络不给力哦~");
		        $(".prompt").fadeIn(300,function(){
		            setTimeout(function(){$(".prompt").fadeOut(300)},3000)
		        })
		    }
		});
	}
})
